package GUI;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.io.IOException;
import java.util.Vector;
import javax.swing.JButton;

import DataObjects.Schedule;
import Messages.MessageGetAllSchedules;
import Messages.MessageGetAllSchedulesReply;
import Messages.MessageShowAllSuppliersReply;
import Messages.MessageShowIDSupplier;
import Messages.MessageShowSupplierIDReply;

public class PanelFunctionsTables extends PanelFunctionsEmpty  {
	
	MainMenu mainMenu;
	
	public PanelFunctionsTables(MainMenu mm)
	{
		super();
		this.mainMenu=mm;
		this.add(get_button_buildSchedule());
		this.add(get_button_changeSchedule());
	}
	
	private JButton get_button_buildSchedule()
	
	{
		JButton buildScheduleBtn=new JButton("סידור שולחנות חדש");
		buildScheduleBtn.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 15));				
		buildScheduleBtn.setPreferredSize(new Dimension(220, 30));
		buildScheduleBtn.addActionListener(new java.awt.event.ActionListener() 
		   {
			public void actionPerformed(java.awt.event.ActionEvent e) 
			{ 
				((BorderLayout) mainMenu
						.getContentPane().getLayout())
						.getLayoutComponent(BorderLayout.CENTER).setVisible(false);
				mainMenu.getContentPane().remove(((BorderLayout)mainMenu.getContentPane().getLayout()).getLayoutComponent(BorderLayout.CENTER));
				mainMenu.getContentPane().add(new PfNewTableSchedule(mainMenu), BorderLayout.CENTER);							
				mainMenu.getContentPane().validate();			
			}								
		});
		return buildScheduleBtn;
	}

	
	
private JButton get_button_changeSchedule()
	
	{
		JButton changeScheduleBtn=new JButton("שינוי סידור");
		changeScheduleBtn.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 15));				
		changeScheduleBtn.setPreferredSize(new Dimension(220, 30));
		changeScheduleBtn.addActionListener(new java.awt.event.ActionListener() 
		   {
			public void actionPerformed(java.awt.event.ActionEvent e) 
			
			{ 
				((BorderLayout) mainMenu
						.getContentPane().getLayout())
						.getLayoutComponent(BorderLayout.CENTER).setVisible(false);
				
				MessageGetAllSchedules msg=new MessageGetAllSchedules();
				try {
					mainMenu.ms.client.sendToServer(msg);
					MessageGetAllSchedulesReply resultSchedules=(MessageGetAllSchedulesReply)mainMenu.ms.client.GetMessage();	
					mainMenu.getContentPane().remove(((BorderLayout)mainMenu.getContentPane().getLayout()).getLayoutComponent(BorderLayout.CENTER));
					mainMenu.getContentPane().add(new PfChangeTableSchedule(mainMenu,resultSchedules.getSchedules()), BorderLayout.CENTER);	
					mainMenu.getContentPane().validate();		
					
				}
				catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
					
			}								
		});
		return changeScheduleBtn;
	}
	
	
}
